package com.atguigu.day02;

import org.omg.CORBA.INTERNAL;

import java.util.HashSet;
import java.util.Set;

/**
 * @ClassName Client
 * @Description 此类描述:hash冲突,一般发生在100000次以后
 * @Author dangchen
 * @DateTime 2022-09-07 18:51
 * @Version 1.0
 */
public class Client {
    public static void main(String[] args) {
       Set set = new HashSet();
       int myHashCode = 0;
        for (int i = 0; i < 110000; i++) {
            myHashCode = new Object().hashCode();
            if (set.contains(myHashCode)){
                System.out.println("----hash冲突发生在第:" + i + "\t次,值为:" + myHashCode);
                continue;
            }
            set.add(myHashCode);
        }
        System.out.println(set.size());
    }
}
